<?php 
if(!defined('INSIDE')){
	exit("Access Denied");
}

execute_action();

function execute_action(){
	global $_GVAR;
	
	$action = $_GVAR['cur_act'];
	$action_result = null;
	
	if(function_exists($action)) {
		$action_result = $action();
	}
	else {
		echo "函数{$action}未定义";
	}
	
	$_GVAR['action_result'] = $action_result;
}

function index() {
	if(C::curr_user() == false) {
		return 'index/login';
	}
	return "index/index";
}

function login() {
	$username = $_POST['username'];
	$password = $_POST['password'];
	if($username == "edward" && $password == "edward") {
		$_SESSION['curr_user'] = "edward";
		return "index/index";
	}
	else {
		return 'index/login';
	}
}

function logout() {
	unset($_SESSION['curr_user']);
	return 'index/login';
}

?>